package com.hk.activity;

import java.util.List;

import com.gc.materialdesign.widgets.SnackBar;
import com.hk.R;
import com.hk.adapter.QAdapter;
import com.hk.biz.BLL;
import com.hk.model.Question;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;

public class ListQuestionActivity extends Activity {

	private QAdapter questionAdapter;
	private String mQType;
	private ListView mlistQuestion;
	private Button mbtn_back;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_list);

		mlistQuestion = (ListView) this.findViewById(R.id.listQuestion);
		mbtn_back = (Button) this.findViewById(R.id.btn_back);

		Bundle bundle = this.getIntent().getExtras();
		mQType = bundle.getString("QuestionType");

		List<Question> listQuestion = BLL.getQuestionListByType(
				getApplicationContext(), mQType);

		if (listQuestion != null && listQuestion.size() > 0) {
			questionAdapter = new QAdapter(this, listQuestion);
			mlistQuestion.setAdapter(questionAdapter);
		}

		mbtn_back.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				finish();
			}
		});
	}

}
